<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="Content-type" content="text/html; charset=utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0">
		<link href="css/text.css" type="text/css" rel="stylesheet" />
		<link href="css/add.css" type="text/css" rel="stylesheet" />
		<link rel="stylesheet" href="css/style.css">
		<script type="text/javascript" src="js/jquery-3.3.1.min.js" ></script>
		<script type="text/javascript" src="js/popups.js"></script>
		<script>
			setSize();
       		addEventListener('resize',setSize);
       		function setSize() {
            	document.documentElement.style.fontSize = document.documentElement.clientWidth/750*100+'px';
            }
       		var configJson='js/confing.json'
       		var ip,stuid;
       		var nosubmitdata=[],
       			submitdata=[];
       		$(function(){
       			$.getJSON(configJson,function(data){
				ip=data.urlip;
				identi()
       			getid()
       			$("#nocomp").addClass("active");
       			$("#comp").addClass("active")
       			});
       		});
       		function identi()
			{
				
				$.ajax({
     				type: "get",
   					url: ip+"/user/type",
  					data:{
  						
  					},
    				dataType: "json",
     				xhrFields: {withCredentials: true},
    				crossDomain:true,
    				success: function(res) {
    					console.log("sssss")
    					console.log(res)
						if(res.code==0)
						{
							type=res.data;//0是老师，1是学生
							$("#exit").html("注销")
						}
						else{
							window.location.href="login.html"
						}
    				},
    				async:false
     			});
			}
			
			function exit(){
				$.ajax({
					type:"get",
					url:ip+"/logout",
					data:{},
					async:true,
					dataType: "json",
					xhrFields: {withCredentials: true},
      				crossDomain:true,
      				success:function(res)
      				{
      					if(!res.code){
      					window.location.href="login.html"
      					}
      				}
				});
			}
       		function getid(){
       			$.ajax({
						type:"get",
						url:ip+"/user/id",
						data:{},
						async:true,
						dataType: "json",
						xhrFields: {withCredentials: true},
      					crossDomain:true,
      					success:function(res)
      					{
      						if(!res.code){
      							stuid=res.data;
      							getlist(stuid);
      							getsubmit(stuid);
      						}
      					}
      			});
       		}
       		
       		function getlist(studi){
       			$.ajax({
						type:"get",
						url:ip+"/client/surveyName",
						data:{
							
						},
						async:true,
						dataType: "json",
						xhrFields: {withCredentials: true},
      					crossDomain:true,
      					success:function(res)
      					{
      						if(!res.code){
      							
      							 $("#nosubmit").html(res.data.total);
      							 nosubmitdata=res.data.survey;
      							 getnosubmit_list(nosubmitdata)
      						}
      					}
      			});
       		}
       		
       		function getnosubmit_list(data){
       			var info="";
       			$.each(data, function(index, value) {
       				info=info+"<div style=' background: white;margin-left: .3rem;font-size: .38rem;margin-right: .3rem;padding: 2% 4.5% 7%;border-radius:.2rem;margin-top:2%;border-bottom:2px solid #dadada' onclick='to_edit(this.id)' id='"+value.id+"'>"
       					+"<p style='width: 80%;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;margin:0'>"+value.title+"</p>"+"<span style='float: right;font-size: .3rem;'>待填写</span></div>";
       			});
       			$("#nosubmit-block").html(info)
       		}
       		
       		function getsubmit_list(data){
       			var info="";
       			for(one in data){
       				info=info+"<div style=' background: white;margin-left: .3rem;font-size: .38rem;border-radius:.2rem;margin-right: .3rem;padding: 2% 4.5% 7%;border-bottom:2px solid #dadada';margin-top:2%' onclick='to_look(this.id)' id='"+data[one]+"'>"
       					+"<p style='width: 80%;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;margin:0'>"+one+"</p>"+"<span style='float: right;font-size: .3rem;'>已填写</span></div>";
       			};
       			$("#submit-block").html(info)
       		}
 
       		function getsubmit(studi){
       			$.ajax({
						type:"get",
						url:ip+"/client/submitsName",
						data:{
							
						},
						async:true,
						dataType: "json",
						xhrFields: {withCredentials: true},
      					crossDomain:true,
      					success:function(res)
      					{
      						if(!res.code){
      							  $("#submit").html(res.data.total);
      							  submitdata=res.data.submits
      							  getsubmit_list(submitdata)
      						}
      					}
      			});
       		}
       		function to_edit(nid)
       		{
       			console.log(nid)
       			window.location.href="from.html?aid="+nid;
       		}
       		function to_look(nid)
       		{
       			console.log(nid);
       			window.location.href="answerfrom.html?id="+nid;
       		}
		</script>
	</head>
	<body style="width: 100% ;height: 100%; background:rgba(243, 243, 243, 0.64);">
		<div id="welcomTex" style="position: fixed;top: 0;width: 100%; ">
			<div style="align-content: center;display: inline;margin-left: 3%;display: inline;">浙商大,</div>
			<div style="display: inline;font-size: .32rem;">欢迎您</div>
			<a id="exit"  onclick="exit()" style="font-size: .3rem;float: right;margin-right: .2rem;"></a>
		</div>
		<div style="width: 100%;margin: 15% 0 0 0;">
			<div id="nocomp" style="background: rgba(254, 255, 223, 0.54);"><strong>待填写问卷</strong><span style="float: right;"><strong id="nosubmit" style="color: red;opacity: .6;"></strong>份</span></div>
			<div id="nosubmit-block"></div>
			<div id="comp" style="background: rgba(254, 255, 223, 0.54);"><strong>已填写问卷</strong><span style="float: right;"><strong id="submit" style="color: green;opacity: .6;"></strong>份</span></div>
			<div id="submit-block"></div>
		</div>
		<div style="text-align: center;text-decoration: none;margin: 6% 0 0 0 ;"><a style="text-decoration: none;font-size: .32rem;" href="https://wj.qq.com/s/2953793/5f86/">有问题点击这里告诉我们</a></div>
	
	</body>
</html>
